package com.zzyl.controller;

import com.zzyl.base.ResponseResult;
import com.zzyl.dto.RoomDto;
import com.zzyl.service.RoomService;
import com.zzyl.vo.RoomVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/room")
@Api(tags = "房间管理")
public class RoomController extends BaseController {
    @Autowired
    private RoomService roomService;

    /**
     * 新增房间
     * @param roomDto 房间信息
     * @return 操作结果
     */
    //新增房间
    @PostMapping("/add")
    @ApiOperation(value = "新增房间", notes = "传入房间信息")
    public ResponseResult addRoom(@ApiParam(value = "房间信息",readOnly = true) @RequestBody RoomDto  roomDto) {
        int rows = roomService.addRoom(roomDto);
        return toAjax(rows);
    }

    /**
     * 删除房间
     * @param id id
     * @return 操作结果
     */
    //删除房间
    @DeleteMapping("/delete/{id}")
    @ApiOperation(value = "删除房间", notes = "传入房间id")
    public ResponseResult deleteRoomById(@ApiParam(value = "房间ID", required = true) @PathVariable("id")  Long id) {
        int rows = roomService.deleteRoomById(id);
        return toAjax(rows);
    }

    /**
     * 查询全部房间
     * @return 房间信息
     */
    //查询全部房间
    @GetMapping("/getAll")
    @ApiOperation(value = "获取所有房间（所有楼层）", notes = "传入房间id")
    public ResponseResult<List<RoomVo>> getAllRoomVos() {
        return success(roomService.getAllRoomVos());
    }


    /**
     * 根据id查询房间
     * @param id id
     * @return 房间信息
     */
    //根据id查询房间
    @GetMapping("/get/{id}")
    @ApiOperation(value = "根据id查询房间", notes = "传入房间id")
    public ResponseResult<RoomVo> getRoomById(@ApiParam(value = "房间ID", required = true) @PathVariable("id")  Long id) {
        return success(roomService.getRoom(id));
    }


    /**
     * 修改房间
     * @param roomDto 房间信息
     * @return 操作结果
     */
    //修改房间
    @PutMapping("/update")
    @ApiOperation(value = "修改房间", notes = "传入房间信息")
    public ResponseResult updateRoom(@ApiParam(value = "房间信息",readOnly = true) @RequestBody RoomDto  roomDto) {
        int rows = roomService.updateRoom(roomDto);
        return toAjax(rows);
    }






    @GetMapping("/getRoomsByFloorId/{floorId}")
    @ApiOperation("获取所有房间（入住配置）")
    public ResponseResult<List<RoomVo>> getRoomsByFloorId(@PathVariable Long floorId) {
        return success(roomService.getRoomsByFloorId(floorId));
    }


    @GetMapping("/getRoomsCheckedByFloorId/{floorId}")
    @ApiOperation("获取所有房间（床位房型）")
    public ResponseResult<List<RoomVo>> getRoomsCheckedByFloorId(@PathVariable Long floorId) {
        return success(roomService.getRoomsCheckedByFloorId(floorId));
    }

    @GetMapping("/getRoomsWithNurByFloorId/{floorId}")
    @ApiOperation("获取所有房间（负责老人）")
    public ResponseResult<List<RoomVo>> getRoomsWithNurByFloorId(@PathVariable Long floorId) {
        return success(roomService.getRoomsWithNurByFloorId(floorId));
    }

}






//    /**
//     * 添加房间
//     * @param roomDto 房间信息
//     * @return 操作结果
//     */
//    @PostMapping("/add")
//    @ApiOperation("添加房间")
//    public ResponseResult addRoom(@ApiParam(value = "房间信息", readOnly = true)@RequestBody RoomDto roomDto) {
//        return toAjax(roomService.addRoom(roomDto));
//    }
//
//    @DeleteMapping("/delete/{id}")
//    @ApiOperation("删除房间")
//    public ResponseResult deleteRoom(@PathVariable Long id) {
//        return toAjax(roomService.deleteRoom(id));
//    }
//
//    @PutMapping("/update")
//    @ApiOperation("更新房间")
//    public ResponseResult updateRoom(@RequestBody RoomDto roomDto) {
//        return toAjax(roomService.updateRoom(roomDto));
//    }
//
//    @GetMapping("/get/{id}")
//    @ApiOperation("获取房间")
//    public ResponseResult<RoomVo> getRoom(@PathVariable Long id) {
//        return success(roomService.getRoom(id));
//    }
//
//    @GetMapping("/getAllVo")
//    @ApiOperation("获取所有房间（所有楼层）")
//    public ResponseResult<List<RoomVo>> getAllRoomVos() {
//        return success(roomService.getAllRoomVos());
//    }